﻿using System;
using System.Collections.Generic;
using Citi.RoutineBase;
using Citi.GocAttributes.Domain;
using System.IO;
using System.Configuration;

namespace Citi.GocAttributes.SchedulerUI
{
    public class UpdateViewOtherSystems : IExecutableRoutine
    {
        public IEnumerable<RoutineParameter> Parameters { get { return null; } }

        public void Rollback(ref ICurrentAction currentAction, Dictionary<string, object> parameters)
        {

        }

        public void Start(DateTime scheduledDate, ref ICurrentAction currentAction, Dictionary<string, object> parameters)
        {
            new RuleApplication(currentAction).UpdateViewOtherSystems();
            FillExpenseCodes(currentAction);
        }

        public void FillExpenseCodes(ICurrentAction currentAction)
        {
            currentAction.Description = "Getting Expense Codes";
            var expenses = new GocRule().GetExpenseCode();

            var expenseCodeFilePath = ConfigurationManager.AppSettings["ExpenseCodeFile"];

            currentAction.Description = "Filling file";
            File.WriteAllLines(expenseCodeFilePath, expenses);

            currentAction.Description = "Process Finished";
        }

        public void Stop(ref ICurrentAction currentAction, Dictionary<string, object> parameters)
        {

        }
    }
}
